//
//  RankingListDetailTableViewCell.m
//  安好
//
//  Created by qinlongqing on 14-9-10.
//  Copyright (c) 2014年 冯凯. All rights reserved.
//

#import "RankingListDetailTableViewCell.h"

@interface RankingListDetailTableViewCell ()
{
    UILabel *numberLabel;
    
    UIImageView *touXiangImageView;
    
    UILabel *testUserNameLabel;
    
    UILabel *testResultLabel;
}
@end

@implementation RankingListDetailTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        UIImageView *cellLine = [[UIImageView alloc]initWithFrame:CGRectMake(0, 39, kScreenWidth, 1)];
        cellLine.backgroundColor = UIColorFromRGB(0xecf4f6);
        [self.contentView addSubview:cellLine];
        
        numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 40, 40)];
        numberLabel.backgroundColor = [UIColor clearColor];
        numberLabel.textAlignment = NSTextAlignmentCenter;
        numberLabel.textColor = UIColorFromRGB(0x4fc1e9);
        numberLabel.font = [UIFont systemFontOfSize:23];
        numberLabel.adjustsFontSizeToFitWidth = YES;
        [self.contentView addSubview:numberLabel];
        
        touXiangImageView = [[UIImageView alloc]initWithFrame:CGRectMake(55, 12, 16, 16)];
        touXiangImageView.image = [UIImage imageNamed:@"pai_hang_bang_touXiang"];
        [self.contentView addSubview:touXiangImageView];
        
        testUserNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 0, 110, 40)];
        testUserNameLabel.backgroundColor = [UIColor clearColor];
        testUserNameLabel.textAlignment = NSTextAlignmentLeft;
        testUserNameLabel.font = [UIFont systemFontOfSize:13];
        testUserNameLabel.adjustsFontSizeToFitWidth = YES;
        [self.contentView addSubview:testUserNameLabel];
        
        testResultLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth - 125, 0, 110, 40)];
        testResultLabel.backgroundColor = [UIColor clearColor];
        testResultLabel.textAlignment = NSTextAlignmentRight;
        testResultLabel.font = [UIFont systemFontOfSize:13];
        testResultLabel.textColor = [UIColor grayColor];
        testResultLabel.adjustsFontSizeToFitWidth = YES;
        [self.contentView addSubview:testResultLabel];
        
    }
    return self;
}

- (void)setup{
    
}

- (void)updata{
    if (self.isBenDiBang) {//本地榜
        numberLabel.text = [NSString stringWithFormat:@"%ld",self.indexPath.row + 1];
        NSString *testUserName = [self.dataEntity objectForKey:@"testUserName"];
        testUserName = [testUserName substringToIndex:testUserName.length - 12];
        testUserNameLabel.text = testUserName;
        
        if (self.currentTestType == shiLiTest) {
            testResultLabel.text = [NSString stringWithFormat:@"左眼:%.1f  右眼:%.1f",[AppConfig getShiLiLevelWithWordSize:[[self.dataEntity objectForKey:@"leftResult"] integerValue]],[AppConfig getShiLiLevelWithWordSize:[[self.dataEntity objectForKey:@"rightResult"] integerValue]]];
        }
    }
    else{//全球榜
        numberLabel.text = [NSString stringWithFormat:@"%@",[self.dataEntity valueForKey:@"order"]];
        testUserNameLabel.text = [NSString stringWithFormat:@"%@",[self.dataEntity valueForKey:@"username"]];
        
        if (self.currentTestType == shiLiTest) {
            testResultLabel.text = [NSString stringWithFormat:@"左眼:%@  右眼:%@",[self.dataEntity valueForKey:@"left_vision"],[self.dataEntity valueForKey:@"right_vision"]];
        }
    }
    
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
